<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <h:head>
        <meta charset="utf-8"/>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
        <link href="./resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
        <title>Facelets Template</title>
        <h:outputStylesheet name="css/jsfcrud.css"/>
    </h:head>

    <h:body>


        <div id="top" class="top">
            <ui:insert name="top">Welcome to ticket manager system!</ui:insert>
            <div style="float:right">
                <h:form>
                    <h:panelGroup rendered="#{not empty sessionScope.user}">
                        <h:outputText value="user "/>
                        <h:outputText value="#{sessionScope.user.userName}"/>
                        <h:commandButton value="logout" action="#{login.doLogout()}"/>
                    </h:panelGroup>
                    <h:panelGroup rendered="#{empty sessionScope.user}">
                        <h:commandButton value="login" action="login"/>
                    </h:panelGroup>

                </h:form>
            </div>
        </div>
        <div>
            <div id="left">
                <ui:insert name="left">
                    <h:form>
                        <h:panelGroup>
                            <ul>                        
                                <li><a href="index.xhtml">Index</a></li> 
                                <li><h:commandLink action="#{initialDatabaseController.initialDatabase()}" value="initial"/></li>
                            </ul> 
                        </h:panelGroup>

                        <h:panelGroup rendered="#{sessionScope.user.userGroup eq 'USER'}">
                            <ul>                        
                                <li><a href="createProblem.xhtml">Create Problem</a></li>
                                <li><a href="listProblemByProcess.xhtml">listProblemByProcess</a></li>
                                <li><a href="listProblemByProduct.xhtml">listProblemByProduct</a></li>
                                <li><a href="searchProblem.xhtml">SearchProblem</a></li>
                            </ul> 
                        </h:panelGroup>

                        <h:panelGroup rendered="#{sessionScope.user.userGroup == 'ADMIN'}">
                            <ul>                        
                                <li><a href="createUser_Tic.xhtml">Create User</a></li>
                                <li><a href="listUser.xhtml">List User</a></li>
                                <li><a href="createProduct.xhtml">Create Product</a></li>
                                <li><a href="listProducts.xhtml">List Products</a></li>
                                <li><h:commandLink action="#{listUserController.listAllUsers()}" value="List all users"/></li>
                            </ul> 
                        </h:panelGroup>
                        <!-- LU Chenyu Part -->
                        <h:panelGroup rendered="#{sessionScope.user.userGroup == 'MANAGER'}">

                            <ul>
                                <li><a href="listProblems.xhtml">List problems</a></li>     
                            </ul>

                        </h:panelGroup>
                    </h:form>
                </ui:insert>
            </div>
            <div id="content" class="left_content">
                <ui:insert name="content">Content</ui:insert>
            </div>
        </div>
    </h:body>

</html>
